from django import template

register = template.Library()

def empty_exclude(value, item):
    """Return list if there are items other than item"""
    if item == None:
        return value
    if value == None or value.count() == 0:
        return None
    if value.count() == 1:
        for val in value:
            if val.pk == item:
                return None
    return value
    
register.filter('empty_exclude', empty_exclude)